<?php

/**
 * Message form.
 *
 * @package    Redsea20
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class MessageForm extends BaseMessageForm
{
  public function configure()
  {
      $messageControls = new sfWidgetFormInput();
      $messageControls->setAttributes(array(
//          'onclick' => 'javascript:LoadUserConnectionList();',
          'class'   =>  'ui-autocomplete-input required',
          'id'  =>  'txtMailTo',
          'style'   =>  'width:96%'));  // As this ID (i-e txtMailTo) is referenced in javascript for popup, so set it here explicitly
      //$w->setAttributes(array('class'   =>  'ui-autocomplete-input'));

      $this->setWidgets(array(
          'email'       =>      $messageControls,
          'subject'     =>      new sfWidgetFormInputText(),
          'body'        =>      new sfWidgetFormTextArea(),
      ));

      $this->widgetSchema['subject']->setAttribute('style', 'width:96%');
      $this->widgetSchema['body']->setAttribute('style', 'width:96%; padding: 5px');

//      $this->setDefaults(array(
//          'email'   =>  'Email Address',
//          'subject' =>  'Subject',
//          'body'    =>  'Body'
//      ));

      $this->widgetSchema->setNameFormat('message[%s]');
      //$this->widgetSchema->setFormFormatterName('list');
//      $this->widgetSchema->setLabel('email', 'Your email address');

      // Set Validators
      $this->setValidators(array(
          'email'   =>  new sfValidatorEmail(),
          'subject' =>  new sfValidatorString(array('min_length' => 1), array('required' => true)),
          'body'    =>  new sfValidatorString(array('min_length' => 1), array('required' => true)),
      ));
  }
}
